package mybatisPlugin.dao;

import mybatisPlugin.entity.User;
import mybatisPlugin.entity.UserPhone;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author caihe
 * @date 2022/10/25 17:25
 */
public interface UserDao {

    @Select("select * from user where id=#{id}")
    List<User> getUserName(@Param("id") String id);

    @Update("update user set name=#{name} where id = #{id} ")
    int update(User user);


    @Select("select * from user where id = #{id}")
    @Results( value = {
            @Result(property = "id", column = "id"),
            @Result(property = "userPhones", column = "id",
                    javaType = List.class,
                    many = @Many(select = "getUserPhone")),
    })
    List<User> getUserNames(@Param("id") String id);

    @Select("select * from user_phone where user_id = #{id}")
    List<UserPhone> getUserPhone(@Param("id") String userId);

}
